package cn.bitkit.tools.data;


import cn.bitkit.base.util.StringUtil;

public class MaskUtil {
	
	public static String mask(String data, int headerLength, int starLength, int tailLength) {
		if(StringUtil.isEmpty(data)){
			return null;
		}
		String head = StringUtil.getHead(data, headerLength);
		String star = StringUtil.leftPad("", '*', starLength);
		String tail = StringUtil.getTail(data, tailLength);
		return head + star + tail;
	}
	
	public static String name(String name) {
		return mask(name, 1, 2, 0);
	}
	
	public static String phone(String phone) {
		return mask(phone, 3, 4, 4);
	}
	
	public static String email(String email) {
		return mask(email, 2, 4, 4);
	}
	
	public static String idCard(String idCard) {
		return mask(idCard, 4, 4, 4);
	}
	
	public static String bankCard(String bankCard) {
		return mask(bankCard, 4, 4, 4);
	}

	public static String password(String password) {
		return mask(password, 0, 6, 0);
	}

}
